const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin")
const json5 = require('json5')
module.exports = {
  mode: "development",
  entry: "./index.js",
  output: {
    filename: "index.js",
    path: path.resolve(__dirname, "dist"),
    //输出清理
    clear:true
  },
  // 自动生成html
  plugins: [
    new HtmlWebpackPlugin({
        template: './index.html'
    })
  ],
  // 开启server
  devServer: {
    static: "./dist",
  },
  // 解析css资源
  module:{
      rules:[
          {
              test:/\.css$/i,
            //   从后往前执行
              use:["style-loader","css-loader"]
          },
          {
            test: /\.json5$/i,
            type: "json",
            parser: {
              parse: json5.parse,
            },
          },
        ]
  }
};